/*
 * @LastEditTime: 2023-04-15 18:54:10
 */
import { router } from "../index";
import { User } from "../../Models/User.schema";
import { UserController } from "../../Controller/User.controller";
import { AuthController } from "../../Controller/Auth.controller";
import { createUserDTO, updataUserDTO } from "../../DTO/User.dto";
import { StringMappingType } from "typescript";

const UserModel = new UserController(User);
const AuthModel = new AuthController(User);

//注册
router.post("/register", async (ctx, next) => {
  console.log(ctx.request.body)
  ctx.body = await AuthModel.register(ctx, ctx.request.body as createUserDTO);
  // next();
});

// 登录
router.post("/login", async (ctx, next) => {
  ctx.body = await AuthModel.login(
    ctx,
    ctx.request.body as { username: string; password: string }
  );
  // next();
});
// 登录
router.get("/userinfo", async (ctx, next) => {
  ctx.body = await AuthModel.login(
    ctx,
    ctx.request.body as { username: string; password: string }
  );
  // next();
});
